import common_functions as cf
import time
# ③.sum(lst):用于求列表中所有元素的和
# 练习：求等差数列（从5开始，到10005结束，公差位3的数列）的和
cf.cut_block("sum学习")
lst3 = range(5, 10_0000_0009, 3)
star_time = time.time()
sum_lst = sum(lst3)
print(sum_lst)
end_time = time.time()
print("这一段代码运行了{}秒".format(end_time - star_time))


cf.cut_block("通过公式计算")
time_start = time.time()
a1 = 5
an = 10_0000_0009 - (10_0000_0009 - 5) % 3
n = len(lst3)
Sn = (a1 + an) * n // 2
print(Sn)
time_end = time.time()
print("这一段代码运行了{}秒".format(time_end - time_start))